<template>
	<view>
		<!-- #ifdef MP -->
		<view class="navbar-wrap" :style="{height:`${CustomBar}px`}">
			<view :style="{height:`${CustomBar}px`,paddingTop:`${Custom.top}px`}" :class="['navbar-cont',bgColor]">
				<view class="navbar-cont-item" :style="{height:`${Custom.height}px`,right:`${Custom.width}`}">
					<text v-if="isBack" class="cuIcon-back" @tap="goBack"/>
					<slot name="content" />
				</view>
			</view>
		</view>
		<!-- #endif -->

		<!-- #ifdef H5 -->
		<view class="navbar-wrap" style="height: 101rpx;">
			<view :class="['navbar-cont',bgColor]">
				<view class="navbar-cont-item">
					<!-- 返回按钮 -->
					<view style="margin-left:10rpx;width:60rpx;box-sizing: border-box;" v-if="isBack" @click="goBack">
						<text class="cuIcon-back" @click="goBack"/>
					</view>

					<!-- 插槽 -->
					<view style="flex:1;">
						<slot name="content" />
					</view>

					<!-- title -->
					<view class="title-cont" v-if="title">
						<text>
							{{title}}
						</text>
					</view>
				</view>
			</view>
		</view>
		<!-- #endif -->
	</view>
</template>

<script>
	export default {
		name: 'cu-custom',
		props: {
			bgColor: {
				type: String,
				default: 'bg-white'
			},
			isBack: {
				type: [Boolean, String],
				default: false
			},
			title: {
				type: String,
				default: ""
			}
		},
		methods: {
			goBack() {
				uni.navigateBack({
					delta: 1
				});
			}
		}
	}
</script>

<style lang="scss" scoped>
	/* #ifdef MP */
	.navbar-wrap {
		position: relative;
		width: 100%;

		.navbar-cont {
			position: fixed;
			top: 0;
			left: 0;
			right: 0;

			&-item {
				display: flex;
				justify-content: space-between;
				align-items: center;
				position: absolute;
				left: 0;
				padding: 0 10rpx;
				box-sizing: border-box;
			}
		}
	}

	/* #endif */


	/* #ifndef MP */
	.navbar-wrap {
		position: relative;
		width: 100%;

		.navbar-cont {
			position: fixed;
			top: 0;
			left: 0;
			right: 0;
			height: 101rpx;
			padding-top: 20rpx;
			z-index: 1000;

			&-item {
				display: flex;
				justify-content: space-between;
				align-items: center;
				padding: 0 10rpx;
				position: relative;

				.title-cont {
					position: absolute;
					left: 60rpx;
					right: 60rpx;
					top: 0;
					display: flex;
					justify-content: center;
					align-items: center;
				}
			}
		}
	}

	/* #endif */
</style>
